package com.xd.study.utility;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

/**
 * Created by DGF on 2015/5/5.
 */
public class MyBroadcastReceiver2 extends BroadcastReceiver {


    @Override
    public void onReceive(Context context, Intent intent) {

        String msg = intent.getStringExtra("msg");
        Toast.makeText(context, "receiver2 接收到的广播消息：" + msg, Toast.LENGTH_SHORT).show();

        /**
         * 接收消息
         * 对于普通广播：无法接收到MyBroadcastReceiver发送的处理结果
         * 对于有序广播，可以接收到MyBroadcastReceiver发送的处理结果
         */
        Bundle bundle = getResultExtras(true);
        String s2 = bundle.getString("test");
        Toast.makeText(context, "receiver2接收到receiver1的处理结果："+s2, Toast.LENGTH_SHORT).show();
    }
}
